package com.example.administrator.newsapp;

import android.support.v4.app.FragmentTabHost;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TextView;

public class showHappyActivity extends AppCompatActivity {

    private FragmentTabHost mTabHost;
    private String[] tabs={
            "文本笑话","图片笑话"
    };
    private String[] tags={
            "http://route.showapi.com/341-1",
            "http://route.showapi.com/341-2",
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_happy);
        mTabHost=findViewById(android.R.id.tabhost);
        mTabHost.setup(showHappyActivity.this,getSupportFragmentManager(),android.R.id.tabcontent);
//        mTabHost.getTabWidget().setDividerDrawable(null);

        for (int i = 0; i <tabs.length ; i++) {
            TabHost.TabSpec spec = mTabHost.newTabSpec(tags[i]);
            spec.setIndicator(getItemView(i));
            mTabHost.addTab(spec,JokeFragmentTab.class,null);
        }
    }

    private View getItemView(int i) {
        View view = LinearLayout.inflate(showHappyActivity.this,R.layout.joke_tabs,null);
        TextView textView = view.findViewById(R.id.tv_tabs);
        textView.setText(tabs[i]);
        return view;
    }
}
